package com.example.majiang.mapper;

import com.example.majiang.model.Comment;
import com.example.majiang.model.Question;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {
    @Insert("insert into comment(parentId,type,commentor,gmtCreate,gmtModified,content,likeCount) values(#{parentId},#{type},#{commentor},#{gmtCreate},#{gmtModified},#{content},#{likeCount})")
    void insert(Comment comment);
    @Select("select * from comment where id=#{parentId}")
    Comment findByParentId(@Param("parentId") Integer parentId);
    @Select("select * from comment where parentId=#{parentId} and type=#{type}")
    List<Comment> findById(@Param("parentId") Integer parentId,@Param("type") Integer type);
    @Update("update comment set commentCount=#{commentCount}+commentCount where id=#{id}")
    void incCommentCount(Comment comment);
}
